# -*- coding: utf-8 -*-
# May Saint Diana bless your coding!
# Created Time : 2021/12/2 15:30
# Author:Zhou Chenghao

import numpy as np
import matplotlib.pyplot as plt
from ANC_tools import FIR_Identify

if __name__ == '__main__':
    # 读取实验数据
    path = "次级通道建模数据.csv"  # 输入是传递给次级扬声器播放的信号（高斯白噪声，能激发出所有频段），输出是在误差传感器处采集到的误差信号
    data = np.loadtxt(path, delimiter=",")

    x = data[:, 0]  # 输入是传递给次级扬声器播放的信号（高斯白噪声，能激发出所有频段）
    d = data[:, 1]  # 输出是在误差传感器处采集到的误差信号
    (w, error) = FIR_Identify(x, d, 16, 0.05)
    print(w)
    plt.plot(error)
    plt.show()
